<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模拟写一个data的监听2</title>
</head>

<body>

</body>
<script>


    let student = { id: "001", name: "张三", age: 18 }
    const obj = new jt(student)
    function jt(obj) {
        Object.defineProperty(this, 'name', {
            set(val) {
                console.log(name + "被修改了");
                obj.name = val
            },
            get() {
                console.log(name + "被获取了");
                return obj.name
            }
        })
    }

</script>

</html>